﻿using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace Eamon.MeituanDotnetSDK.model.ddzh.tuangou.tuangouReceiptPrepare
{
    /// <summary>
    /// 输码验券校验
    /// </summary>
    public class TuangouReceiptPrepareResponse
    {
        /// <summary>
        /// 可验证的张数
        /// </summary>
        [JsonPropertyName("count")]
        public int? Count { get; set; }

        /// <summary>
        /// 订单ID
        /// </summary>
        [JsonPropertyName("orderId")]
        public string OrderId { get; set; }

        /// <summary>
        /// 验证券码
        /// </summary>
        [JsonPropertyName("receiptCode")]
        public string ReceiptCode { get; set; }

        /// <summary>
        /// 套餐ID（若验证的券所对应的商品为团购时，该字段必返回），次卡（平台次卡，不是团购次卡）和拼团不返回此参数
        /// </summary>
        [JsonPropertyName("dealId")]
        public long? DealId { get; set; }

        /// <summary>
        /// 团购ID，团购id与套餐id是一对多的关系（若验证的券所对应的商品为团购时，该字段必返回），次卡（平台次卡，不是团购次卡）和拼团不返回此参数
        /// </summary>
        [JsonPropertyName("dealGroupId")]
        public long? DealGroupId { get; set; }

        /// <summary>
        /// 商品名称
        /// </summary>
        [JsonPropertyName("dealTitle")]
        public string DealTitle { get; set; }

        /// <summary>
        /// 商品售卖价格
        /// </summary>
        [JsonPropertyName("dealPrice")]
        public double? DealPrice { get; set; }

        /// <summary>
        /// 商品市场价
        /// </summary>
        [JsonPropertyName("dealMarketPrice")]
        public double? DealMarketPrice { get; set; }

        /// <summary>
        /// 用户手机号
        /// </summary>
        [JsonPropertyName("mobile")]
        public string Mobile { get; set; }

        /// <summary>
        /// 业务类型 0:普通团购  203:拼团 205:次卡 217:通兑标品
        /// </summary>
        [JsonPropertyName("bizType")]
        public int? BizType { get; set; }

        /// <summary>
        /// 支付明细(订单维度，如果订单有多张券可以通过订单券码分摊金额查询接口查询)
        /// </summary>
        [JsonPropertyName("paymentDetail")]
        public List<PaymentDetailSub> PaymentDetail { get; set; }

        /// <summary>
        /// 券过期时间
        /// </summary>
        [JsonPropertyName("receiptEndDate")]
        public long? ReceiptEndDate { get; set; }

        /// <summary>
        /// 是否是团购次卡
        /// </summary>
        [JsonPropertyName("tgTimesCardFlag")]
        public bool? TgTimesCardFlag { get; set; }

        /// <summary>
        /// 团购次卡可用总次数
        /// </summary>
        [JsonPropertyName("purchaseToConsumeRatio")]
        public string PurchaseToConsumeRatio { get; set; }

        /// <summary>
        /// 团购次卡单次卡价格（单位：分）
        /// </summary>
        [JsonPropertyName("timesCardUnitPrice")]
        public string TimesCardUnitPrice { get; set; }

        /// <summary>
        /// 补贴金额（平台分摊）
        /// </summary>
        [JsonPropertyName("platformAmount")]
        public string PlatformAmount { get; set; }

        /// <summary>
        /// 补贴金额（商户分摊）
        /// </summary>
        [JsonPropertyName("merchantAmount")]
        public string MerchantAmount { get; set; }

        /// <summary>
        /// 体检加项信息
        /// </summary>
        [JsonPropertyName("additionItemInfos")]
        public List<RadditionItemInfo> AdditionItemInfos { get; set; }

        /// <summary>
        /// 商品类型 1、泛商品如丽人派样活动商品等（若验证的券所对应的商品非团购时，该字段必返回）
        /// </summary>
        [JsonPropertyName("productType")]
        public long? ProductType { get; set; }

        /// <summary>
        /// 商品ID（若验证的券所对应的商品非团购时，该字段必返回，productItemId含义参考商品管理API）
        /// </summary>
        [JsonPropertyName("productItemId")]
        public long? ProductItemId { get; set; }

        /// <summary>
        /// 三方商品ID（仅限家居、珠宝行业）
        /// </summary>
        [JsonPropertyName("thirdPartyProductId")]
        public string ThirdPartyProductId { get; set; }

        /// <summary>
        /// Map<Long, List<ReceiptPrepareResult>> JSON格式。多团单维度券信息，如果为null则为单团单,key为productItemId
        /// </summary>
        [JsonPropertyName("receiptInfoMap")]
        public string ReceiptInfoMap { get; set; }

        /// <summary>
        /// 商品类型，0：普通商品，1：支持在线付尾款
        /// NOTE: 此字段官网文档里没有，java sdk里是Integer类型
        /// </summary>
        [JsonIgnore]//BUG:类型不明确System.InvalidOperationException: Cannot get the value of a token type 'String' as a number.
        [JsonPropertyName("dealType")]
        public int DealType { get; set; }

        public override string ToString()
        {
            return $"TuangouReceiptPrepareResponse{{Count={Count}, OrderId={OrderId}, ReceiptCode={ReceiptCode}, DealId={DealId}, DealGroupId={DealGroupId}, DealTitle={DealTitle}, DealPrice={DealPrice}, DealMarketPrice={DealMarketPrice}, Mobile={Mobile}, BizType={BizType}, PaymentDetail={PaymentDetail}, ReceiptEndDate={ReceiptEndDate}, TgTimesCardFlag={TgTimesCardFlag}, PurchaseToConsumeRatio={PurchaseToConsumeRatio}, TimesCardUnitPrice={TimesCardUnitPrice}, PlatformAmount={PlatformAmount}, MerchantAmount={MerchantAmount}, AdditionItemInfos={AdditionItemInfos}, ProductType={ProductType}, ProductItemId={ProductItemId}, ThirdPartyProductId={ThirdPartyProductId}, ReceiptInfoMap={ReceiptInfoMap}, DealType={DealType}}}";
        }
    }
}

